package com.yixuan.mt.core.handler;

import com.yixuan.mt.core.exception.HttpMethodNotSupportException;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 请求分发Controller
 */
@Component
public class DoRequest {

   @Autowired
   private GetFileController getFileController;

   @Autowired
   private PostFileController postFileController;

    public AbstractController handle(HttpRequest request) {
        if (request.method().equals(HttpMethod.GET)) {
            return getFileController;
        } else if (request.method().equals(HttpMethod.POST)) {
            return postFileController;
        }
        throw new HttpMethodNotSupportException();
    }
}
